package perfectNumber;

public class Main {
    public static void main(String[] args) {
        int limit = 10000;
        for (int num = 1; num <= limit; num++) {
            if (isPerfectNumber(num)) {
                System.out.println(num);
            }
        }
    }

    private static boolean isPerfectNumber(int num) {
        if (num <= 1) {
            return false;
        }
        int sum = 1;
        for (int i = 2; i <= Math.sqrt(num); i++) {
            if (num % i == 0) {
                sum += i;
                int otherDivisor = num / i;
                if (otherDivisor != i) {
                    sum += otherDivisor;
                }
            }
        }
        return sum == num;
    }
}
